//
//  Macro.h
//  NoneCar
//
//  Created by DongSen on 2018/7/11.
//  Copyright © 2018年 董森森. All rights reserved.
//

#ifndef Macro_h

#define Macro_h

#define  APPBOUNDLENAME @"NoCarboundle1" //设置appname


#define  kJudgeFirst  [[NSUserDefaults standardUserDefaults] valueForKey:APPBOUNDLENAME]

#define  kSaveFirst  [[NSUserDefaults standardUserDefaults] setValue:@"NO" forKey:APPBOUNDLENAME]

#define SCREEN_W [UIScreen mainScreen].bounds.size.width
#define SCREEN_H [UIScreen mainScreen].bounds.size.height

#define iPhone4_OR_4s    (SCREEN_H == 480)
#define iPhone5_OR_5c_OR_5s   (SCREEN_H == 568)
#define iPhone6_OR_6s   (SCREEN_H == 667)
#define iPhone6Plus_OR_6sPlus   (SCREEN_H == 736)
#define iPhoneX   (SCREEN_H == 812)

#define Font(x) [UIFont systemFontOfSize:x]

#define RGBColor(r,g,b) [UIColor colorWithRed:(r)/255.0f green:(g)/255.0f blue:(b)/255.0f alpha:1]
#define RGBAColor(r,g,b,a) [UIColor colorWithRed:(r)/255.0f green:(g)/255.0f blue:(b)/255.0f alpha:(a)]
#define RGB16Color(rgbValue) [UIColor colorWithRed:((float)((rgbValue & 0xFF0000) >> 16))/255.0 green:((float)((rgbValue & 0xFF00) >> 8))/255.0 blue:((float)(rgbValue & 0xFF))/255.0 alpha:1.0]
#define STRCOLOR(string) [UIColor colorWithHexString:string]

#define kSCREEN_W [UIScreen mainScreen].bounds.size.width

#define kSCREEN_H [UIScreen mainScreen].bounds.size.height

#define WeakSelf(self)  __weak typeof(self) weakSelf = self

#define StrongSelf(weakSelf) __strong typeof(weakSelf) strongSelf = weakSelf


#define kSTATUSBARHEIGGT ((([UIApplication sharedApplication].statusBarFrame.size.height==40||[UIApplication sharedApplication].statusBarFrame.size.height==64)?([UIApplication sharedApplication].statusBarFrame.size.height-20):[UIApplication sharedApplication].statusBarFrame.size.height))

#define kNAVIGATIONTITLEHEIGHT 44

#define kNAVIGATIONBARHEIGHT ((kNAVIGATIONTITLEHEIGHT)+(kSTATUSBARHEIGGT))

#define kTabBarHeight                        self.tabBarController.tabBar.bounds.size.height

#define iOS8 ([[[UIDevice currentDevice] systemVersion] floatValue] >= 7.0)
//判断是否是iOS10
#define iOS10 ([[[UIDevice currentDevice] systemVersion] floatValue] >= 10.0&&[[[UIDevice currentDevice] systemVersion] floatValue] <11.0)
#define iPhoneX ([UIScreen instancesRespondToSelector:@selector(currentMode)] ? CGSizeEqualToSize(CGSizeMake(1125, 2436), [[UIScreen mainScreen] currentMode].size) : NO)
//判断是否是iOS11
#define iOS11 ([[[UIDevice currentDevice] systemVersion] floatValue] >= 11.0)

//判断字符串为空
#define NULLString(string) ((![string isKindOfClass:[NSString class]])||[string isEqualToString:@""] || (string == nil) || [string isEqualToString:@""] || [string isKindOfClass:[NSNull class]]||[[string stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceCharacterSet]] length]==0)

#ifdef DEBUG
#define VMLog(FORMAT, ...) printf("%s\n", [[NSString stringWithFormat:FORMAT, ##__VA_ARGS__] UTF8String]);
#else
#define VMLog(...)

#endif


#ifndef dispatch_queue_async_safe
#define dispatch_queue_async_safe(queue, block)\
if (strcmp(dispatch_queue_get_label(DISPATCH_CURRENT_QUEUE_LABEL), dispatch_queue_get_label(queue)) == 0) {\
block();\
} else {\
dispatch_async(queue, block);\
}
#endif

#ifndef dispatch_main_async_safe
#define dispatch_main_async_safe(block) dispatch_queue_async_safe(dispatch_get_main_queue(), block)
#endif

#endif /* Macro_h */
